<?php

/*

Template Name: Page Postfolio1

*/

global $body_id;

$body_id = "portfolio-2col";

get_header();

wp_enqueue_script('filterable');	

$posts_per_page = 6;//get_theme_option('portfolio','portfolio_post_per_pages');



#

#Get Paged

#

if ( get_query_var('paged') ) {

	$paged = get_query_var('paged');

} elseif ( get_query_var('page') ) { 

	$paged = get_query_var('page');

} else {

	$paged = 1;

}

//$sort = get_theme_option('portfolio','portfolio_sort');

$args = array(

	'post_type' => 'portfolio',

	'taxonomy' => 'categories',

	'showposts' => $posts_per_page,

	'paged' => $paged,

	'order' => 'ASC'

);

			   if(is_page())

                {

                	query_posts($args);

                }else{

                	global $wp_query;

                	$query_args = array_merge( $wp_query->query, $args );

                	global $posts;

                	$posts=query_posts($query_args);

                }

?>

<div class="eight columns">

<?php

		$the_query = new WP_Query($args);

		$i = 1;

		echo '<div class="row">';

		$count=$the_query->post_count;

		while ($the_query->have_posts() ) : $the_query->the_post();?>

		<div class="twelve columns <?php   if($i==$count) echo 'end';?>"  >

					<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>

					<p><?php echo get_the_excerpt(); ?></p>

				</div>

			<?php if($i % 1==0){			

			echo '</div>';

			echo '<div class="row">';

			  $i++;

			}else  {

			$i++;

			}

		?>

	<?php 

	endwhile;	?>

	</div>
	<div class="row">
		<div class="eight columns">
		
			<!-- Begin Pagination -->
		
			<?php if (function_exists("emm_paginate")) {
		
			    emm_paginate();
		
			} else{
		
			echo posts_nav_link();
		
			}
		
			?>	        	
		
			<!-- End Pagination -->
		
		</div>
	</div>
</div>

	

<?php get_sidebar(); ?>

<?php

get_footer();

?>